package com.sourny.ribbon.hystrix.server.service;

import com.netflix.hystrix.contrib.javanica.annotation.HystrixCommand;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.web.client.RestTemplate;

/**
 * @author sourny.yang
 * @date 2018/3/31 13:12
 */
@Service
public class HelloService {

    @Autowired
    private RestTemplate restTemplate;

    @HystrixCommand(fallbackMethod = "sayHelloError")
    public String sayHello() {
        return restTemplate.getForEntity("http://SERVICE-A/hello", String.class).getBody();
    }
    public String sayHelloError(){
        return "Server is error!";
    }
}
